package com.lizhi.yun.webservice.config;

import com.lizhi.yun.webservice.CommonService;
import com.lizhi.yun.webservice.WebService;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

/**
 * @Author: lizhi
 * @Description: cxf发布WebService服务,默认服务在ip:port/services/**路径下面
 * @Date: create in 2020/9/15 15:34
 */
@Configuration
public class CxfConfig {

    @Autowired(required = false)
    private Bus bus;

    @Autowired(required = false)
    private CommonService commonService;

    @Autowired(required = false)
    private WebService webService;

    @Bean
    public Endpoint endpointCommonService(){
        EndpointImpl endpoint = new EndpointImpl(bus, commonService);
        endpoint.publish("/CommonService");
        return endpoint;
    }

    @Bean
    public Endpoint endpointWebService(){
        EndpointImpl endpoint = new EndpointImpl(bus, webService);
        endpoint.publish("/WebService");
        return endpoint;
    }
}
